/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TMS;

/**
 *
 * @author Zachary
 */
public class Input_Device {
    private static String input_string;             /* A string of user input */
    private static boolean ready = false;           /* Signals that the inut string has something */
    public static void clear(){
        input_string = "";
        ready = false;
    }
    public static void append(String value){
        input_string += value;        
    }
    public static void backspace(){
        input_string = input_string.substring(0, input_string.length()-1);        
    }
    public static String getInput(){
        if (ready == true){
            String temp = new String(input_string);
            input_string = "";
            ready = false;
            return temp;
        }
        else{
            return "";
        }
    }
    public static String input_value(){
        return input_string;
    }
    public static void set_ready(boolean value){
        ready = value;
    }
    public static boolean is_ready(){
        return ready;
    }
    public static boolean isNumeric(){
        if (input_string.isEmpty()) return false;
        for (int i = 0; i < input_string.length(); i++){
            if (input_string.charAt(i) < '0' || input_string.charAt(i) > '9')return false;
        }
        return true;
    }
}
